
#include<iostream>
#include<unistd.h>
#include<sys/types.h>
using namespace std;

int main()
{
  //cout<<"father_id"<<getpid()<<endl;
  //fork();
  //cout<<"father_id"<<getpid()<<endl;


 cout<<"father_id:"<<getpid()<<endl;
 pid_t id = fork();
 if(id<0)
 {
   cout<<"false"<<endl;
 }
 else if(id==0)
 {
   while(1)
   {
  sleep(1);
   cout<<"child_id:"<<getpid()<<endl;
   }
 }
 else
 {
   while(1)
   {
  sleep(1);
   cout<<"father_id:"<<getpid()<<" "<<getppid<<endl;
   }
 }
cout<<endl;



  //while(1)
  //{
  //  sleep(1);
  //  cout<<"进程id:"<<getpid()<<"父进程id："<<getppid()<<endl;
  //}
  return 0;
}
